package com.fundynamic.jbehave;

import junit.framework.Assert;

import org.jbehave.core.annotations.Given;
import org.jbehave.core.annotations.Then;
import org.jbehave.core.annotations.When;
import org.jbehave.core.embedder.Embedder;

import com.fundynamic.codekata.CheatingException;
import com.fundynamic.codekata.Frame;

public class BowlingGameSteps extends Embedder {

	private Frame frame;

	@Given("any frame")
	public void anyFrame() {
		frame = new Frame();
	}

	@When("first roll knocks down $amount pins")
	public void rollFirst(int amount) throws CheatingException {
		frame.roll(amount);		
	}

	@When("second roll knocks down $amount pins")
	public void rollSecond(int amount) throws CheatingException {
		frame.roll(amount);		
	}
	
	@Then("amount of knocked down pins is $total")
	public void amountKnockedDownMustEqual(int total) {
		Assert.assertEquals(total, frame.totalPinsNockedDown());
	}
}
